<template>
	<view class="order">
		<!-- 列表 -->
		<view class="listBox">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="list_l">
					<image :src="item.user.avatar" mode=""></image>
					<view class="list_l_r">
						<view class="name">{{item.name||''}}</view>
						<view class="name">
							<view class="">
								{{item.mobile||''}}
							</view>
							<view class="icon" v-if="item.mobile" @tap.stop="callPhone(item.mobile)">
								<image src="../static/images/index/call.png" mode=""></image>
							</view>
						</view>
					</view>
				</view>
				<view class="list_r" :style="{width:item.status !=0 ?'21%':'40%'}">
					<view class="time">{{item.createtime_text}}</view>
					<view class="haveBtn" v-if="item.status !=0 "
						:style="{color: item.status == 1?'#2CB9A4':'#FF7575'}">
						{{item.status == 2 ? '已驳回':'已同意'}}
					</view>
					<view class="" style="display: flex;width: 100%;" v-if="item.status ==0 ">
						<view class="btn" :style="{backgroundColor:'#2CB9A4'}" @tap="isPick(item,2)">
							{{'驳回'}}
						</view>
						<view class="btn" :style="{backgroundColor:'#FF7575'}" @tap="isPick(item,1)">
							{{'同意'}}
						</view>
					</view>

				</view>
			</view>

		</view>

		<!-- 提示栏 -->
		<view class="more">{{isText}}</view>

	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				list: [],
				isText: '',
				last_page: 1
			};
		},
		onLoad() {

		},
		onShow() {
			this.init()
			this.getList()
		},
		methods: {
			init() {
				this.list = []
				this.page = 1
				this.isText = ''
			},
			// 获取员工列表
			async getList() {
				let that = this
				await uni.request({
					url: '/wanlshop/user/staffExamineList',
					data: {
						page: this.page
					},
					success: res => {
						that.list = that.list.concat(res.data.data)
						that.last_page = res.data.last_page
						res.data.total == that.list.length ? that.isText = '暂无数据' : that.isText = ''
						console.log(that.list, 'that.list')
					}
				});

			},
			// 点击审核
			isPick(el, type) {
				if (el.status != 0) return
				console.log(el, type, 'elel')
				let that = this
				let statusText = type == 1 ? '同意' : '驳回'

				uni.showModal({
					title: `${statusText}员工申请`,
					content: '',
					editable: true, //是否显示输入框
					placeholderText: '理由', //输入框提示内容
					confirmText: '确认',
					cancelText: '取消',
					success: (res) => {
						if (res.confirm) {
							uni.request({
								url: '/wanlshop/user/staffExamine',
								data: {
									id: el.id,
									status: type,
									remark: res.content
								},
								success: res => {
									uni.showToast({
										title: res.msg,
										icon: 'none'
									})
									this.init()
									this.getList()
								}
							});
						} else {
							
						}
					}
				});
			},
			// 点击拨号
			callPhone(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber,
				});
			},
			// 跳转到详情页面
			goDetails(el) {
				let res = {
					order_number: el.order_number,
					goods_img: el.goods_img,
					goods_name: el.goods_name
				}
				uni.navigateTo({
					url: '/pages/order/details/details?res=' + JSON.stringify(res)
				})
			}
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
				that.getList()
			}
		}

	}
</script>

<style lang="less">
	page {
		background-color: #f9f9f9;
	}

	.more {
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		margin: 30rpx auto;
		padding-bottom: 50rpx;
	}

	.u-tab-bar {
		display: none !important;
	}

	uni-modal .uni-modal__bd {
		white-space: pre-wrap;
	}

	.order {
		width: 100vw;

		.tabBox {
			width: 100%;
			height: 160rpx;

			.card {
				width: 90%;
				height: 100%;
				background: #2CB9A4;
				border-radius: 20rpx;
				margin: 20rpx auto;
				display: flex;
				padding: 20rpx 20rpx 20rpx 50rpx;
				justify-content: space-between;

				.card_1 {
					color: #fff;
					align-items: center;

					.my {
						font-weight: 600;
						font-size: 36rpx;
					}

					.curr {
						font-weight: 600;
						font-size: 40rpx;
						padding-right: 10rpx;
						margin-top: 16rpx;
					}
				}

				.card_2 {
					width: 30%;
					text-align: center;
					margin: 40rpx 0 40rpx 60rpx;
					background-color: #fff;
					border-radius: 20rpx;
					color: #2CB9A4;
					font-size: 26rpx;
				}
			}
		}

		.listBox {
			width: 95%;
			margin: 30rpx auto;

			.list {
				width: 100%;
				height: auto;
				padding: 20rpx;
				border-radius: 20rpx;
				background-color: #fff;
				margin: 20rpx auto;
				display: flex;
				justify-content: space-between;

				.list_l {
					width: 64%;
					display: flex;
					align-items: center;

					image {
						width: 84rpx;
						height: 84rpx;
						border-radius: 50%;
					}

					.list_l_r {
						font-size: 28rpx;
						font-weight: 400;
						margin-left: 20rpx;

						.name {
							height: 46rpx;
							line-height: 46rpx;
							display: flex;

							.icon {
								margin: 4rpx 4rpx 10rpx 14rpx;
								width: 30rpx;
								height: 30rpx;
								box-sizing: border-box;

								image {
									width: 30rpx;
									height: 30rpx;
								}
							}
						}
					}
				}

				.list_r {
					width: 21%;
					font-size: 24rpx;
					text-align: right;

					.time {
						color: #979797;
						margin-bottom: 10rpx;
					}

					.haveBtn {
						font-size: 24rpx;
						width: 96%;
						text-align: right;
					}

					.btn {
						color: #fff;
						font-size: 22rpx;
						width: 88%;
						border-radius: 38rpx;
						text-align: center;
						padding: 8rpx;
						margin: 8rpx 10rpx;
					}
				}
			}
		}
	}
</style>